<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="btn">btn</button>
    <script>
        // bind使用场景
         var id =1001;
        var btn = document.getElementById("btn")
        btn.onclick = function(){
            // 1 使用变量
            var that = this;
            setTimeout(function(){
                console.log(that.id)
            },1000)
            
            // 2 bind
            // setTimeout(function(){
            //     console.log(this.id)
            // }.bind(btn),1000)

            // 3 箭头
            // setTimeout(()=>{
            //     console.log(this.id)
            // },1000)
        }
    </script>
</body>
</html>